package com.fzfnn.scrapbook.controller;

import com.fzfnn.scrapbook.service.PicturesService;
import com.fzfnn.scrapbook.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;


@RestController
@RequestMapping("/pictures")
@Tag(name = "图片接口", description = "图片功能接口")
public class PicturesController {
    @Autowired
    private PicturesService picturesService;
    @PostMapping("/avatar")
    @Operation(summary = "上传头像")
    public R uploadAvatar(@RequestParam("file") MultipartFile file,
                          @RequestHeader("Authorization") String token,
                          HttpServletRequest request) throws IOException {
        return picturesService.avatar(file, token, request);
    }
    @PostMapping("/scrappictures")
    @Operation(summary = "上传手账图片")
    public R uploadScrapPictures(@RequestParam("file") List<MultipartFile> files,
                                 @RequestHeader("Authorization") String token,
                                 HttpServletRequest request) throws IOException {
        return picturesService.scrappictures(files, token, request);
    }



}
